<?php
class Blog extends CI_Controller{
	/**
	 *
	 * 构造函数
	 */
	function Blog()
	{
		parent::__construct();
		// load helpers
		$this->load->helper('url');
		//$this->load->helper('form');
		//$this->load->helper(array('form','url'));
		//$this->form_validation->//...
		//$this->load->library('form_validation');
	}

	/**
	 * 首页
	 */
	function index() {
		$this->load->model('MBlog', 'blog');
		$data['blogs'] =$this->blog->get_last_ten_datanews();
		$this->load->view('blog/index');
	}
	function add(){
		//$this->load->helper('date');
		// display information for the view
		$this->load->library('ckeditor');
		$this->ckeditor->basePath = base_url().'ckeditor/';
		$this->ckeditor->returnOutput = true;
		$data['ckeditor'] = $this->ckeditor->editor('content');
		$this->load->view('blog/add', $data);
	}
	/**
	 * 插入页面
	 * @param unknown_type $data
	 */
	function insert(){
		//设置数据格式
		date_default_timezone_set('Asia/Shanghai');
		//构造插入数据的数组
		$data = array(
		            'title'=>$_POST['title'],
		            'content'=>$_POST['content'],
		            'creatdate'=>date("Y-m-d H:i:s")
		);
		$this->load->model('MBlog', 'blog');
		$this->blog->saveBlog($data);
	}
}
?>